package org.brisling.workflow.service.base;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.brisling.common.ConstSysParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.ModelAndView;
/**
 * 
 * 默认服务基类，调用spring默认 <code>EntityManager</code>数据访问的业务类可继承该方法
 * @author : jackson wang
 * @Date   : 2015年6月8日 下午9:47:33
 * @version: 1.0
 * @param <T> 泛型需定义的业务类实体
 */
public class BaseWorkflowService{	
	
	protected EntityManager entityManager;
	
	protected String subSystem;
	
	protected String moduleName;
	
	protected String mainPage = "Main";
	
	protected String editPage = "EditDlg";
	
	@PersistenceContext(unitName=ConstSysParam.SUBSYSTEM_SYSMAN)
	@Autowired
	protected void setEntityManager(EntityManager entityManager){
		this.entityManager = entityManager;
		this.subSystem = ConstSysParam.SUBSYSTEM_WORKFLOW;
	}
	
	protected ModelAndView getBizMainPage(){
		String _page = String.format("/%1$s/%2$s/%2$s%3$s", subSystem,moduleName,mainPage);
		return new ModelAndView(_page);		
	}
	
	/**
	 * 获取业务编辑页面
	 * @return
	 */
	
	protected ModelAndView getBizEditPage(){
		String _page = String.format("/%1$s/%2$s/%2$s%3$s", subSystem,moduleName,editPage);
		return new ModelAndView(_page);
	}
	
}
